﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no" />
    <link href="../Frozenui1.3/css/frozen.css" rel="stylesheet" />
    <link href="../JS/Date/FT_Date.min.css" rel="stylesheet" />
    <script src="../JS/layer/layer.m.js"></script>
    <script src="../JS/zepto.min.js"></script>
    <script src="../Frozenui1.3/js/frozen.js"></script>
    <script src="../JS/MobileCom.js?v=1.1"></script>
    <script src="../JS/avalon.min.js"></script>
    <script src="http://cdnjs.gtimg.com/cdnjs/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="../JS/Date/FT_Date.min.js"></script>
    <script>
        var jq = $.noConflict();
        jq(function () {
            var currYear = (new Date()).getFullYear();
            var opt = {
                date: { preset: 'date' },
                defaultopi: {
                    theme: 'android-ics light', //皮肤样式
                    display: 'modal', //显示方式
                    mode: 'scroller', //日期选择模式
                    lang: 'zh',
                    startYear: currYear - 5, //开始年份
                    endYear: currYear + 5, //结束年份
                    onSelect: function (valueText, inst) {
                        bxinfo.ctData.BXDate = valueText;
                    }
                }
            };
            jq("#appSDate").scroller(jq.extend(opt['date'], opt['defaultopi'])).scroller('setDate', new Date(), true);
            bxinfo.ctData.BXDate = jq("#appSDate").val();
        })
    </script>
    <title>新增报销明细</title>
    <style>
        .ui-select {
            border: none;
            border: 0;
            background-color: #fff;
            appearance: none;
            -moz-appearance: none; /* Firefox */
            -webkit-appearance: none; /* Safari 和 Chrome */
        }
        .ms-controller, [ms-controller] {
            display: none;
        }
    </style>

    <script type="text/javascript">
        var width = 0;
        var bxinfo = avalon.define({
            $id: "bxinfo",
            ctData: { "LeiBie": "", "BXDate": "","BXContent":"", "BXJE": "" },
            savedata: function () {
                var lg = $.loading({
                    content: '保存中...',
                })
                $.post("/API/WXAPI.ashx?Action=ADDJFBXITEM&r=" + Math.random(), { "P1": JSON.stringify(bxinfo.ctData.$model) }, function (data) {
                    lg.hide();
                    var data = $.parseJSON(data);
                    if (data.ErrorMsg == "") {
                        $(".ui-footer").hide();
                        var el = $.tips({
                            content: "保存成功！",
                            stayTime: 2000,
                            type: "success"
                        })
                        el.on("tips:hide", function () {
                            window.location.reload();
                        })
                    }
                    else {
                        $.tips({
                            content: "保存失败，原因：" + data.ErrorMsg,
                            stayTime: 2000,
                            type: "warn"
                        })
                    }
                })
            },
            bjk: function () {

                var tc = layer.open({
                    type: 1,
                    //content:$("#bmxx").html(),
                    //title: "活动简介",
                    content: '<div class="ui-form-item ui-form-item-textarea ui-border-b" style="width:' + (width - 76) + 'px;height:200px"><textarea id="hdjjbjk" style="padding-left: 0;height:170px;border: 1px solid #e0e0e0;" placeholder="请输入事由">' + bxinfo.ctData.BXContent + '</textarea></div>',
                    btn: ['确认', '取消'],
                    shadeClose: false,
                    yes: function () {
                        bxinfo.ctData.BXContent = $("#hdjjbjk").val();
                        if ($("#hdjjbjk").val() != "") {
                            $("#hdjj").removeClass("ui-txt-muted");
                            $("#hdjj").html($("#hdjjbjk").val());
                        }
                        else {
                            $("#hdjj").addClass("ui-txt-muted");
                            $("#hdjj").html("请输入事由");
                        }

                        layer.close(tc);

                    }, no: function () {
                    }
                })
            }

        });
        avalon.ready(function () {
            width = document.documentElement.clientWidth;
            var lg = $.loading({
                content: '加载中...',
            })
            $.post("/API/WXAPI.ashx?Action=GETCOLUMNLIST&r=" + Math.random(), { "P1": "4" }, function (data) {
                lg.hide();
                var data = $.parseJSON(data);
                if (data.ErrorMsg == "") {
                    $("select").empty();
                    for (var i = 0; i < data.Result.length; i++) {
                        $("select").append('<option value="' + data.Result[i].TypeNO + '">' + data.Result[i].TypeNO + '</option>');
                        if (i == 0) {
                            bxinfo.ctData.LeiBie = data.Result[i].TypeNO;
                        }
                    }
                }
                else {
                    $.tips({
                        content: "消费类别加载失败，原因：" + data.ErrorMsg,
                        stayTime: 2000,
                        type: "warn"
                    })
                }
            })
        })
</script>

</head>
<body ms-controller="bxinfo">

    <header class="ui-header ui-header-stable ui-border-b">
        <i class="ui-icon-return" onclick="history.back()"></i><h1>新增消费记录</h1>
    </header>
    <div class="ui-footer ui-footer-stable ui-btn-group ui-border-t">
        <button class="ui-btn-lg ui-btn-primary" ms-click="savedata()">
            保存
        </button>
        <button class="ui-btn-lg" onclick="history.back()">
            取消
        </button>
    </div>
    <section class="ui-container">
        <div class="ui-form ui-border-t">
            <div class="ui-form-item ui-border-b ">
                <label>
                    消费类别
                </label>
                <div class="ui-select ui-border-b">
                    <select  ms-duplex="ctData.LeiBie"></select>
                </div>
            </div>
            <div class="ui-form-item ui-border-b">
                <label>
                    时间
                </label>
                <div class="ui-select ui-border-b">
                    <input type="text" placeholder="请输入时间" id="appSDate" ms-duplex="ctData.BXDate" style="padding-left:0" />
                </div>
            </div>
            <div class="ui-form-item ui-border-b">
                <label>
                    金额(元)
                </label>
                <input type="text" placeholder="请输入金额" ms-duplex="ctData.BXJE" />

            </div>
            <div class="ui-form-item  ui-border-b" style="height:auto;min-height:44px">
                <label>
                    事由
                </label>
                <div class="ui-txt-muted ui-whitespace" style="padding-left: 95px;text-align:justify" id="hdjj" ms-click="bjk()">请输入事由</div>
                <!--<input type="text" placeholder="请输入事由" ms-duplex="ctData.BXContent" />-->
            </div>
            <div class="ui-form-itemui-border-b">
                <div class="ui-btn-wrap">
                    图片
                </div>
            </div>
            <div class="ui-form-item ui-border-b">
                <a class="ui-icon-add"></a>
            </div>

        </div>
    </section>

    <div class="ui-dialog">
        <div class="ui-dialog-cnt">
            <div class="ui-dialog-ft ui-btn-group">
                <button type="button" data-role="button" class="select" id="dialogButton<%=i%>">关闭</button>
            </div>
        </div>
    </div>
</body>
</html>
